package Component;

import java.util.ArrayList;

public class Container extends Component{
    private String name;
    private ArrayList<Component> clist=new ArrayList<Component>();
    public Container(String name){
        this.name=name;
    }

    @Override
    public void add(Component com) {
        clist.add(com);
    }

    @Override
    public void remove(Component com) {
        clist.remove(com);
    }

    @Override
    public Component getChild(int i) {
        return (Component) clist.get(i);
    }

    @Override
    public void usecontrol() {
        System.out.println("正在使用容器控件中");
        for(Object obj:clist){
            ((Component)obj).usecontrol();
        }
    }
}
